#include "qsignalslotcenter.h"
#include "pickmanager.h"

QSignalSlotCenter::QSignalSlotCenter* QSignalSlotCenter::QSignalSlotCenter::_eventCenter = NULL; 

namespace QSignalSlotCenter
{
	QSignalSlotCenter::QSignalSlotCenter()
	{
		VrDataCore::PickManager::GetInstance().registerPickObjectChangeEvent("QSignalSlotCenter",
			&QSignalSlotCenter::pickObjectsChanged,this);
	}

	QSignalSlotCenter::~QSignalSlotCenter()
	{}

	QSignalSlotCenter& QSignalSlotCenter::GetInstance()
	{
		if(_eventCenter == NULL)
			_eventCenter = new QSignalSlotCenter;
		return *_eventCenter;
	}

	void QSignalSlotCenter::pickObjectsChanged()
	{
		QVector<CoreBase::ActorBase*> pickobjects = VrDataCore::PickManager::GetInstance().getPickActorObjects();
		emitSelecteActorObjectChanged(pickobjects);
	}

	void QSignalSlotCenter::emitClearAll()
	{
		emit signalClearAll();
	}

	void QSignalSlotCenter::emitCurrentMapChanged()
	{
		emit signalCurrentMapChanged();
	}

	void QSignalSlotCenter::emitCreateDevices(QVector<osg::ref_ptr<CoreBase::ActorBase>> vector,
		QVector<osg::ref_ptr<CoreBase::ActorBase>> targetvector)
	{
		emit signalCreateDevices(vector,targetvector);
	}

	void QSignalSlotCenter::emitActionBeforeCreateDevices(QVector<CoreBase::ActorBase*> vector)
	{
		emit signalActionBeforeCreateDevices(vector);
	}

	void QSignalSlotCenter::emitCreateDevicesWithAction(QVector<osg::ref_ptr<CoreBase::ActorBase>> vector,
			QVector<osg::ref_ptr<CoreBase::ActorBase>> targetvector,int action)
	{
		emit signalCreateDevicesWithAction(vector,targetvector,action);
	}

	void QSignalSlotCenter::emitDoBrush()
	{
		emit signalDoBrush();
	}

	void QSignalSlotCenter::emitManipulatorModeChange(const QString& Mode)
	{
		emit signalManipulatorModeChange(Mode);
	}

	void QSignalSlotCenter::emitManipulatorModeChangeWithObjs(const QString& Mode,QVector<CoreBase::ActorBase*> vector,bool setdefaultstart)
	{
		emit signalManipulatorModeChangeWithObjs(Mode,vector,setdefaultstart);
	}

	void QSignalSlotCenter::emitSelecteActorObjectChanged(QVector<CoreBase::ActorBase*> objects)
	{
		emit signalSelecteActorObjectChanged(objects);
		QVector<QString> objecttypes;
		for(int i=0;i<objects.size();++i)
		{
			objecttypes.push_back(objects.at(i)->getClassName());
		}
		emit signalTypesSelecteActorObjectChanged(objecttypes);
	}

	void QSignalSlotCenter::emitRunCreateDeleteCommand(QVector<osg::ref_ptr<CoreBase::ActorBase>> vector,
			QVector<osg::ref_ptr<CoreBase::ActorBase>> targetvector,int action)
	{
		emit signalRunCreateDeleteCommand(vector,targetvector,action);
	}

	void QSignalSlotCenter::emitRunPropertyEditCommand(QVector<CoreBase::ActorBase*> vector,int action)
	{
		emit signalRunPropertyEditCommand(vector,action);
	}

	void QSignalSlotCenter::emitChangeUndoRedoActionState(int action,int state)
	{
		emit signalChangeUndoRedoActionState(action,state);
	}

	void QSignalSlotCenter::emitActorPropertyChanged(QVector<CoreBase::ActorBase*> actor,QVector<QString> oldval,
			QVector<QString> newval,QString propertyname)
	{
		emit signalActorPropertyChanged(actor,oldval,newval,propertyname);
	}

	void QSignalSlotCenter::emitActorPropertyChangedWithAction(QVector<CoreBase::ActorBase*> actor,QVector<QString> oldval,
			QVector<QString> newval,QString propertyname,int action)
	{
		emit signalActorPropertyChangedWithAction(actor,oldval,newval,propertyname,action);
	}

	void QSignalSlotCenter::emitActionTrigger(int action)
	{
		emit signalActionTrigger(action);
	}

	void QSignalSlotCenter::emitChangeSingleSceneObject(QVector<CoreBase::ActorBase*> actorvector)
	{
		emit signalChangeSingleSceneObject(actorvector);
	}

	void QSignalSlotCenter::emitChangeSceneMode(int mode)
	{
		emit signalChangeSceneMode(mode);
	}

	void QSignalSlotCenter::emitSetLookAtObject(CoreBase::ActorBase* actor)
	{
		emit signalSetLookAtObject(actor);
	}

	void QSignalSlotCenter::emitSetLookAt(QVector<osg::Vec3> attitude)
	{
		emit signalSetLookAt(attitude);
	}

	void QSignalSlotCenter::emitSaveEvent()
	{
		emit signalSaveEvent();
	}
}